#!/bin/bash

# 网站脚本前面必须这样写
echo "Content-Type:text/html;charset=utf8 "
echo ""



export LANG=en_US.UTF-8

# echo "aaaaaaaaaaaaaaa"

# mysql -h10.10.10.81 -ujxadmin -p123456 jxcms -e "select *from jx_stu"

echo "
CTYPE html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <title>学生信息表</title>  
    <style>  
        table {  
            border-collapse: collapse;  
            width: 100%;  
        }  
        th, td {  
            text-align: left;  
            padding: 8px;  
        }  
        th {  
            background-color: #f2f2f2;  
        }  
        tr:nth-child(even) {  
            background-color: #f2f2f2;  
        }  
    </style>  
</head>  
<body>  
  
<h1>学生信息表</h1>  
  
<table>  
    <tr>  
        <th>学号</th>  
        <th>班级号</th>  
        <th>姓名</th>  
        <th>年龄</th>  
    </tr> "
for ((i=1;i<=4;i++));do
stu=$(mysql -h10.10.10.81 -ujxadmin -p123456 jxcms -e "select *from jx_stu" |grep -v id |sed -n $i"p")
id=$(echo $stu | awk -F " " '{print $1}')
calss_id=$(echo $stu | awk -F " " '{print $2}')
name=$(echo $stu | awk -F " " '{print $3}')
age=$(echo $stu | awk -F " " '{print $4}')
echo " 
   <tr>  
        <td>$id</td>  
        <td>$class_id</td>  
        <td>$name</td>  
        <td>$age</td>  
    </tr> "
done  
echo "   <!-- 可以在这里继续添加更多学生信息 -->  
</table>  
  
</body>  
</html> "

